*** NOTE:  This do-file perfroms the constant heterogeneity weight approach used ***
***        for the MSA-level refinance ARM specifications that did not converge  ***
***        using the MNL model with unobserved heterogeneity in Table 6.  This   ***
***        do-file was run separately for each MSA for which the unobserved      ***
***        heterogeneity model did not converge.                                 ***



log using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Logs\20110131 constant mass pt -- full size -- refi_arm -- chi.log", replace



***************************
***************************
*** CHICAGO             ***
*** REFI_ARM            ***
*** FULL SIZE           ***
*** CONSTANT MASS POINT ***
***************************
***************************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Chicago\chicago_both_refi_arm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf with constant mass pt.do"



*****************************
*** MASS POINTS:  50%-50% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.50
	quietly generate double `mass_prob_l2' = 0.50

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", replace onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  55%-45% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.55
	quietly generate double `mass_prob_l2' = 0.45

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  60%-40% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.60
	quietly generate double `mass_prob_l2' = 0.40

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  65%-35% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.65
	quietly generate double `mass_prob_l2' = 0.35

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  70%-30% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.70
	quietly generate double `mass_prob_l2' = 0.30

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  75%-25% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.75
	quietly generate double `mass_prob_l2' = 0.25

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  80%-20% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.80
	quietly generate double `mass_prob_l2' = 0.20

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  85%-15% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.85
	quietly generate double `mass_prob_l2' = 0.15

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



*****************************
*** MASS POINTS:  90%-10% ***
*****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.90
	quietly generate double `mass_prob_l2' = 0.10

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



****************************
*** MASS POINTS:  95%-5% ***
****************************

program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2

	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = 0.95
	quietly generate double `mass_prob_l2' = 0.05

	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end lownodoc cashout fico cltv payment_adj2 adj_1st post_adj_1st spread ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_6molibor vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(100) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20110131 constant mass pt by MSA full size refi_arm chi.txt", append onecol text bracket(se) e(all)
*ml graph

program drop mymlogit_uh_lf



log close



clear



